package cn.hp.cms.utils;

import com.alibaba.fastjson.JSON;

import javax.servlet.ServletResponse;
import java.io.IOException;

// 将java对象转成json字符串、对象
public class JsonForServlet {

//    向页面中写入json数据
    public static void writeData(ServletResponse response , ResultData data){
        try {
            response.getWriter().println(JSON.toJSONString(data));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
